home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- // MODIFY THIS AT YOUR OWN RISK
- //
- // Creation Date: 11 July 1997
- // Author: jb
- //
- //
- // Procedure Name:
- // layerEditorWin
- //
- // Description:
- // Brings up a window that allows users to manage
- // the layers in the system
- //
- // Input Arguments:
- // None.
- //
- // Return Value:
- // None.
- //
-
- proc int isValidName( string $name )
- // Description:
- // This procedure checks if the given string is a valid object
- // name. It returns true if it is, false otherwise.
- //
- {
- int $isValid = true;
- // check if name contains invalid characters
- string $regex = "[^0-9a-zA-Z_]";
- string $match = match( $regex, $name );
- if ($match != "") {
- $isValid = false;
- confirmDialog -title "Alert"
- -button "OK"
- -defaultButton "OK"
- -message " Name contains illegal characters. Please select another. "
- -parent layerEditorWnd;
- } else {
- // check if name begins with an alphabetic character
- $regex = "[a-zA-Z_][0-9a-zA-Z_]*";
- $match = match( $regex, $name );
- if ($match != $name) {
- $isValid = false;
- confirmDialog -title "Alert"
- -button "OK"
- -defaultButton "OK"
- -message " Name is not valid. Please select another. "
- -parent layerEditorWnd;
- }
- }
- return $isValid;
- }
-
- global proc renameLayer( string $currentLayerName ) {
-
- // If it's not the default universe layer then place dialogue
- if ($currentLayerName != "Universe")
- {
- //
- // Prompt the user for a new layer name
- //
- string $result = `promptDialog
- -title "Rename Layer"
- -message "Enter New Layer Name:"
- -text $currentLayerName
- -button "OK"
- -button "Cancel"
- -defaultButton "OK"
- -cancelButton "Cancel"
- -dismissString "Cancel"
- -parent layerEditorWnd`;
-
- //
- // If the result was "OK", then proceed
- //
- if ( $result == "OK" ) {
-
- //
- // Query the promptDialog for the name the
- // user typed in - note: there is no checking
- // being done for illegal characters, spaces,
- // etc. This should be added.
- //
- // The set is created in the layer partition
- // first, then the elements are forced into
- // the set, so that exclusivity can be maintained,
- // and the set creation won't fail before it's
- // even created.
- //
- string $newLayerName = `promptDialog -q`;
-
- if ( isValidName($newLayerName) ) {
- if (catch($newLayerName = `rename $currentLayerName $newLayerName`)) {
- //
- // error due to non - unique name for context
- //
- confirmDialog -title "Alert"
- -button "OK"
- -defaultButton "OK"
- -message " Error in trying to rename Layer. Please select another "
- -parent layerEditorWnd;
- }
- else {
- string $layerEntryName = ( $newLayerName + "LayerItem" );
- string $oldLayerEntryName = ( $currentLayerName + "LayerItem" );
-
- // change the label of the menu item and rename
- // the menu item
- menuItem -e -l $newLayerName $oldLayerEntryName;
- renameUI $oldLayerEntryName $layerEntryName;
- }
- }
- }
- } else {
- warning( "Universe layer cannot be renamed" );
- }
- }
-
-
- global proc updateLayerEditorButtons( )
- {
- // If something is selected in the layer
- // list, then enable the appropriate buttons,
- // otherwise disable the ones that require that
- // sets/layers are selected
- //
- if( 0 == `textScrollList -q -nsi layerList` ) {
- button -e -enable false renameButton;
- button -e -enable false deleteButton;
- button -e -enable false hideButton;
- button -e -enable false showButton;
- button -e -enable false transferButton;
- } else if( 1 == `textScrollList -q -nsi layerList` ) {
- button -e -enable true renameButton;
- button -e -enable true deleteButton;
- button -e -enable true hideButton;
- button -e -enable true showButton;
- button -e -enable true transferButton;
- } else {
- button -e -enable false renameButton;
- button -e -enable true deleteButton;
- button -e -enable true hideButton;
- button -e -enable true showButton;
- button -e -enable false transferButton;
- }
- }
-
-
- global proc updateLayerEditorWnd( )
- {
- // Fill the set list
- //
- textScrollList -e -ra layerList;
-
- string $layers[] = `listAllLayers`;
-
- for( $item in $layers ) {
- textScrollList -e -a $item layerList;
- }
- }
-
-
- global proc layerCmd( string $cmd )
- {
-
-
- switch( $cmd ) {
- case "new":
- createNewLayer;
- updateLayerEditorWnd;
- break;
- case "rename":
- // Rename the selected sets
- string $selSets[] = `textScrollList -q -si layerList`;
- renameLayer $selSets[0];
- updateLayerEditorWnd;
- break;
- case "transfer":
- // Transfer selected to selected layer
- string $selSets[] = `textScrollList -q -si layerList`;
- if( size( `ls -sl` ) == 0 ) {
- warning( "No objects selected to transfer to " + $selSets[0] );
- return;
- }
- sets -e -fe $selSets[0];
- break;
- case "delete":
- // Delete the selected sets
- //
- string $selSets[] = `textScrollList -q -si layerList`;
- for( $set in $selSets ) {
- delete $set;
- }
- updateLayerEditorWnd;
- break;
- case "hide":
- // Hide the selected sets
- //
- string $selSets[] = `textScrollList -q -si layerList`;
- for( $set in $selSets ) {
- hide $set;
- }
- break;
- case "show":
- // Show the selected sets
- //
- string $selSets[] = `textScrollList -q -si layerList`;
- for( $set in $selSets ) {
- showHidden $set;
- }
- break;
- case "hideall":
- // Hide all layer sets
- //
- string $layers[] = `listAllLayers`;
- for( $item in $layers ) {
- hide $item;
- }
- break;
- case "showall":
- // Hide all layer sets
- //
- string $layers[] = `listAllLayers`;
- for( $item in $layers ) {
- showHidden $item;
- }
- break;
- case "select":
- // Select layer sets
- //
- string $selSets[] = `textScrollList -q -si layerList`;
- select -d;
-
- for( $set in $selSets ) {
- select -add $set;
- }
- break;
- case "template":
- // Template layer sets
- //
- string $selSets[] = `textScrollList -q -si layerList`;
- select -d;
-
- for( $set in $selSets ) {
- toggle -template -state on $set;
- }
- break;
- case "untemplate":
- // Template layer sets
- //
- string $selSets[] = `textScrollList -q -si layerList`;
- select -d;
-
- for( $set in $selSets ) {
- toggle -template -state off $set;
- }
- break;
- case "selectall":
- // Select all layer sets
- //
- string $layers[] = `listAllLayers`;
- select -d;
-
- for( $item in $layers ) {
- select -add $item;
- }
- break;
- }
- }
-
-
- global proc layerEditorWin( )
- {
-
- if( `window -exists layerEditorWnd` ) {
- updateLayerEditorWnd;
- showWindow layerEditorWnd;
- return;
- }
-
- // GG: don't hardcode the HEIGHT! It doesn't work X-platform
- window -t "Layer Editor" -w 223
- -iconName "Layers"
- -s true layerEditorWnd;
-
- tabLayout layerEditorTabLayout;
-
- formLayout layerEditorForm;
- textScrollList
- -ams true
- -dkc "layerCmd delete"
- -dcc "layerCmd select"
- -sc "updateLayerEditorButtons"
- layerList;
-
-
- separator -style "in" layerSep;
-
- columnLayout layerEdBtnLayout;
-
- button -h 26 -w 80 -l "New"
- -c "layerCmd new" newButton;
- button -h 26 -w 80 -l "Rename"
- -c "layerCmd rename" -enable false renameButton;
- button -h 26 -w 80 -l "Remove"
- -c "layerCmd delete" -enable false deleteButton;
- button -h 26 -w 80 -l "Transfer"
- -c "layerCmd transfer" -enable false transferButton;
-
- separator -style "in" -w 80 -h 10;
-
- button -h 26 -w 80 -l "Hide"
- -c "layerCmd hide" -enable false hideButton;
- button -h 26 -w 80 -l "Hide All"
- -c "layerCmd hideall" -enable true hideAllButton;
-
- separator -style "in" -w 80 -h 10;
-
- button -h 26 -w 80 -l "Show"
- -c "layerCmd show" -enable false showButton;
- button -h 26 -w 80 -l "Show All"
- -c "layerCmd showall" -enable true showAllButton;
-
- separator -style "in" -w 80 -h 10;
-
- button -h 26 -w 80 -l "Template"
- -c "layerCmd template" -enable true templateButton;
- button -h 26 -w 80 -l "Untemplate"
- -c "layerCmd untemplate" -enable true unTemplateButton;
-
- separator -style "in" -w 80 -h 10;
-
- button -h 26 -w 80 -l "Select"
- -c "layerCmd select" -enable true selButton;
- button -h 26 -w 80 -l "Select All"
- -c "layerCmd selectall" -enable true selAllButton;
-
- setParent ..;
-
- button -h 26 -w 80 -l "Update"
- -c "updateLayerEditorWnd" updateButton;
- button -h 26 -w 80 -l "Close"
- -c "deleteUI layerEditorWnd" closeButton;
- setParent ..;
-
- formLayout -e
- -af layerList top 5
- -ac layerList right 5 layerEdBtnLayout
- -af layerList left 5
- -ac layerList bottom 5 layerSep
-
- -af layerEdBtnLayout top 5
- -af layerEdBtnLayout right 5
- -an layerEdBtnLayout left
- -ac layerEdBtnLayout bottom 5 layerSep
-
- -af layerSep left 0
- -af layerSep right 0
- -ac layerSep bottom 5 updateButton
- -an layerSep top
-
- -af updateButton left 5
- -af updateButton bottom 5
- -ap updateButton right 3 50
- -an updateButton top
-
- -ap closeButton left 2 50
- -af closeButton bottom 5
- -af closeButton right 5
- -an closeButton top
- layerEditorForm;
-
- formLayout characterForm;
- outlinerEditor -mainListConnection characterList
- -selectionConnection highlightList characterOutliner;
- columnLayout characterBtnLayout;
- button -h 26 -w 80 -l "Set Key"
- -c "performSetKeyframeCharacter false"
- keyframeButton;
- button -h 26 -w 80 -l "Set Breakdown"
- -c "performSetBreakdownCharacter false"
- breakdownButton;
-
- separator -style "in" -w 80 -h 10;
-
- button -h 26 -w 80 -l "Clear"
- -c "selectionConnection -edit -clear highlightList"
- clearSelectionButton;
-
- setParent ..;
- formLayout -e
- -af characterOutliner top 5
- -ac characterOutliner right 5 characterBtnLayout
- -af characterOutliner left 5
- -af characterOutliner bottom 5
-
- -af characterBtnLayout top 5
- -af characterBtnLayout right 5
- -an characterBtnLayout left
- -af characterBtnLayout bottom 5
- characterForm;
-
- tabLayout -edit -tabLabel layerEditorForm "Layers"
- -tabLabel characterForm "Characters" layerEditorTabLayout;
-
-
- // Create script jobs to keep the layer editor up to date
- // when new layers are added to the system, File -> New
- // is performed, or a file is imported/opened
-
- scriptJob
- -p "layerEditorWnd"
- -e "layerPartitionModified"
- "updateLayerEditorWnd";
-
- scriptJob
- -p "layerEditorWnd"
- -e "NewSceneOpened"
- "updateLayerEditorWnd";
-
- scriptJob
- -p "layerEditorWnd"
- -e "SceneOpened"
- "updateLayerEditorWnd";
-
- updateLayerEditorWnd;
- showWindow layerEditorWnd;
- }
-